import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout/index.vue'

const routes = [
  {
    path: '/',
    name: 'layout',
    redirect: "/overview",
    component: Layout,
    children: [
      {
        path: "/overview",
        name: "overview",
        component: () => import("@/views/OverView/index.vue"),
      },
      {
        path: "/craft",
        name: "craft",
        component: () => import("@/views/Craft/index.vue"),
      },
      {
        path: "/safe",
        name: "safe",
        component: () => import("@/views/Safe/index.vue"),
      },
      {
        path: "/material",
        name: "material",
        component: () => import("@/views/Material/index.vue"),
      }
    ]
  }
]

const router = createRouter({
  routes,
  history: createWebHashHistory(process.env.BASE_URL),
  // scrollBehavior: (to, from, savedPosition)=> {
  //   console.log(to, from, savedPosition);
  //   return { x: 0, y: 0}
  // },
})
router.afterEach((to, from, next) => {
  console.log(to, from, next);
  window.scrollTo(0,0)
})
export default router
